package com.iot.manage.service;

import com.alibaba.fastjson.JSONObject;
import com.iot.manage.dao.DeviceModelMapper;
import com.iot.manage.pojo.DeviceModel;
import com.iot.manage.pojo.ModelArgs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceModelService {

    @Autowired
    private DeviceModelMapper deviceModelMapper;

    public List<DeviceModel> findDeviceModelList(String query, int pagenum, int pagesize) {
        return deviceModelMapper.findDeviceModelList(query,pagesize * (pagenum - 1),pagesize * pagenum);
    }

    public int countDeviceModelList(String query) {
        return deviceModelMapper.countDeviceModelList(query);
    }

    public void addDeviceModel(JSONObject params) {
        deviceModelMapper.addDeviceModel(params);
    }

    public DeviceModel findDeviceModelByIdOrCode(String params) {
        return deviceModelMapper.findDeviceModelByIdOrCode(params);
    }

    public void updateDeviceModelInfo(JSONObject params) {
        deviceModelMapper.updateDeviceModelInfo(params);
    }

    public void deleteDeviceModelById(String modelId) {
        deviceModelMapper.deleteDeviceModelById(modelId);
    }

    public List<ModelArgs> findPropertyArgsList(String propertyParams) {  return deviceModelMapper.findPropertyArgsList(propertyParams); }

    public List<ModelArgs> findEventArgsList(String eventParams) {
        return deviceModelMapper.findEventArgsList(eventParams);
    }

    public List<ModelArgs> findServiceArgsList(String serviceParams) {
        return deviceModelMapper.findServiceArgsList(serviceParams);
    }

    public void updateDeviceModelArgById(JSONObject params) {
        deviceModelMapper.updateDeviceModelArgById(params);
    }

    public String findModelArgById(String modelId) {
        return deviceModelMapper.findModelArgById(modelId);
    }

    public List<ModelArgs> findPropertyArgsListYes(String propertyParams) {  return deviceModelMapper.findPropertyArgsListYes(propertyParams); }

    public List<ModelArgs> findEventArgsListYes(String eventParams) {
        return deviceModelMapper.findEventArgsListYes(eventParams);
    }

    public List<ModelArgs> findServiceArgsListYes(String serviceParams) {
        return deviceModelMapper.findServiceArgsListYes(serviceParams);
    }
}
